/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package desarrollosoft.ghce.dao.implementaciones;

import desarrollosoft.ghce.dao.interfaces.IConsultaDAO;
import desarrollosoft.ghce.entidades.Consulta;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author ariel
 */
@Repository("consultaDAO")
public class ConsultaDAO implements IConsultaDAO {

    @PersistenceContext
    EntityManager entityManager;
    
    @Override
    @Transactional(propagation = Propagation.MANDATORY)
    public void crearConsulta(Consulta consulta) {
        entityManager.persist(consulta);
    }

    @Override
    @Transactional(propagation = Propagation.MANDATORY)
    public void modificarConsulta(Consulta consulta) {
        entityManager.merge(consulta);
    }

    @Override
    @Transactional(propagation = Propagation.MANDATORY)
    public void eliminarConsulta(Consulta consulta) {
        entityManager.remove( entityManager.merge(consulta) );
    }
    
}
